<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015-5-23
 * Time: 13:36
 */

namespace doumiaoduo\layer;
use yii\base\Widget;

class LayerIframeWidget extends Widget{

    public $button;

    public function init(){
        parent::init();
        if ($this->button === null) {
            $this->button = "['保存', '取消']";
        }
    }

    public function run()
    {
        $view = $this->getView();
//        $view->registerCssFile('/css/css.css');
        LayerAsset::register($view);
        $js_str="

        layer.config({
            extend: ['/skin/customskin/style.css'], //加载您的扩展样式
        });
           $(document).on('click','a[rel=dialog-show-iframe]',function(){
            var btns = [];
            var btn1 = $(this).data('btn1')?$(this).data('btn1'): '保存';
            var btn2 = $(this).data('btn2')?$(this).data('btn2'): '取消';
            btns.push(btn1);
            btns.push(btn2);
            var dialog_size=$(this).data('size');
            var dialog_width=dialog_size.indexOf('*')>0?dialog_size.split('*')[0]:500;
            var dialog_height=dialog_size.indexOf('*')>0?dialog_size.split('*')[1]:500;
           window.iframe_index=layer.open({
           type: 2,
           closeBtn: 1,
           id:'layer-iframe',
           skin: 'layui-iframe-customskin',
           title: [$(this).data('name'), 'font-size:18px;'],
           area: [dialog_width+'px', dialog_height+'px'],
           content: $(this).data('url'),
           btn: btns,
           yes: function(index, layero){
              layer.getChildFrame('#dosubmit', index).click();
           }
           });

        })
         ";
        $view->registerJs($js_str);
    }


}